import time

import grequests
import requests


def use_requests(num):
    start = time.time()
    res_list = [requests.get('http://mocker.test.thinkinpower.net/paymentRecordQuery') for i in range(num)]
    print("【requests】发送{num}个请求，耗时{total_time}".format(num=num, total_time=time.time() - start))


def use_grequests(num):
    start = time.time()
    req_list = [grequests.get('http://mocker.test.thinkinpower.net/paymentRecordQuery') for i in range(num)]
    res_list = grequests.map(req_list)
    print("【grequests】发送{num}个请求，耗时{total_time}".format(num=num, total_time=time.time() - start))


if __name__ == '__main__':
    use_requests(1000)
    use_grequests(1000)
